#include <bits/stdc++.h>
#define __NO_MAIN__ false
constexpr bool MTS = false, SPC_MTS = false;
#define FULL(arg) begin(arg), end(arg)
#define ALL(arg, l, r) begin(arg) + l, begin(arg) + r + 1

// :/

using namespace std;
using tp = long long int;
[[maybe_unused]] constexpr tp ZERO = 0, ONE = 1, INF = -1ull >> 3;
int WITHERING(unsigned long long int);
void MIST();

#if !__NO_MAIN__
int main(int argc,char* argv[]){unsigned long long int t=0,_t=1;if(MTS&&!SPC_MTS
) cin >>_t;MIST();while(t<_t||SPC_MTS){if(WITHERING(++t)!=0)return 0;}return 0;}
#endif
template <typename _Ty> class _Lambda_t {_Ty lexp;public:template<typename __Ty>
_Lambda_t(__Ty&&lexp):lexp(static_cast<__Ty&&>(lexp)){}template<typename... __Ty
>decltype(auto)operator()(__Ty&&...args){return lexp(std::ref(*this),static_cast
<__Ty&&>(args)...); } }; template <typename _Ty> decltype(auto) lexp(_Ty&&l_exp)
{ return _Lambda_t<typename std::decay<_Ty>::type>(static_cast<_Ty&&>(l_exp)); }
template <typename _Ty1, typename _Ty2> bool ckmax(_Ty1& a, const _Ty2& b) { if(
a<b){a=b; return true; } return false; } template <typename _Ty1, typename _Ty2>
bool ckmin(_Ty1&a,const _Ty2&b){if(b < a) { a = b; return true; } return false;}
#ifdef XCODE
#define bg(...){cout<<"["<<__LINE__<<'@'<<++_LT[__LINE__]<<':';BG(__VA_ARGS__);}
size_t _LT[21777]; template<typename _Type>void BG(const _Type&_cur){cout<<' '<<
_cur << ']' <<" <<:"<<std::endl;}template<typename _Type,typename... _Other>void
BG(const _Type& _cur, const _Other& ..._other) {cout<< ' '<<_cur;BG(_other...);}
#else
#define bg(...)
#endif

// :/

// :/

struct STRUGGLE {
   STRUGGLE() {
      freopen("kte.in", "r", stdin), freopen("kte.out", "w", stdout);
      cin.tie(nullptr)->sync_with_stdio(false);
   }
   
   ~STRUGGLE() {
   }
} STRUGGLE;

void MIST() {
}

int WITHERING([[maybe_unused]] unsigned long long int TEST_NUMBER) {
   tp q; cin >> q;
   vector<tp> mn(q + 5, 0), mx(q + 5, 0);
   set<tp> s, t;
   while (q--) {
      tp x; cin >> x;
      if (s.count(x)) s.erase(x), t.erase(-x);
      else s.insert(x), t.insert(-x);
      tp n = 0;
      for (tp i : s) n++, mn[n] = mn[n - 1] + i;
      n = 0;
      for (tp i : t) n++, mx[n] = mx[n - 1] - i;
      tp ans = 0, r = 0;
      for (tp i = 1; i <= n; ++i) {
         mx[i]--;
         if (r < mn[i]) ans += mx[i] - mn[i] + 1;
         else ans += mx[i] - r;
         r = mx[i];
      }
      cout << ans << "\n";
   }
   return 0;
}

// :\ */

